package ModelLayer;
import java.util.ArrayList;
import java.util.Iterator;
/**
 * Write a description of class Person here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Person
{
    private int id;
    private String name;
    private String address;
    private long postalCode;
    private String city;
    private long phone;
    private ArrayList<Loan> loans;

    public Person(int id, String name, String address, long postalCode, String city, long phone)
    {
        this.id = id;
        this.address = address;
        this.name = name;
        this.postalCode = postalCode;
        this.city = city;
        this.phone = phone;
        loans = new ArrayList<Loan>();
    }

    public Person()
    {
    }
    
    
    public void setId(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getAddress()
    {
        return address;
    }

    public void setPostalcode(long postalCode)
    {
        this.postalCode = postalCode;
    }

    public long getPostalcode()
    {
        return postalCode;
    }

    public void setCity(String city)
    {
        this.city = city;
    }

    public String getCity()
    {
        return city;
    }

    public void setPhone(long phone)
    {
        this.phone = phone;
    }

    public long getPhone()
    {
        return phone;
    }

    public void print()
    {
        System.out.println("Id: " + id);
        System.out.println(" Name: " + name);
        System.out.println(" Address: " + address);
        System.out.println(" Postal Code: " + postalCode);
        System.out.println(" City: " + city);
        System.out.println(" Phone No: " + phone);
        System.out.println("");
    }
    
    public void printAllLoans()
    {
        for(Loan loan : loans)
            { 
                loan.printLoanInfo();
            }
        }
    public void setLoan(Loan loan)
        {
            if(loan != null) loans.add(loan);            
        }
    
    public Loan getLoan(int id)
        {
            Loan theLoan = null;
            Iterator<Loan> it = loans.iterator();
            boolean found = false;
            while(it.hasNext() && !found)
                {
                    Loan loan = it.next();
                    if(loan.getId() == id)
                        {
                            theLoan = loan;
                            found = true;                            
                        }
                }
            return theLoan;
        }
}
